﻿using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using GameFramework;
using Plugins.FormicArch.Core;
using UnityEngine;

namespace Example
{
    public class UIMainViewTest : BaseView<MainViewModel>
    {
        public async override Task Awake()
        {
            Register<GameData>(PubliceEventType.None, DataLoad);
            await base.Awake();
        }

        class GameData
        {
        }

        private void DataLoad(GameData data)
        {
        }

        public void Load()
        {
            LoadPrefabAsync("Assets/Res/Streaming/Prefabs/UI/MainWin.prefab", (obj) =>
            {
                obj.transform.SetParent(GameObject.Find("Canvas").transform);
                obj.transform.localPosition = Vector3.zero;
                obj.transform.localScale = Vector3.one;
            });
        }

        public async Task LoadAsync()
        {
            GameObject obj = await LoadPrefabAsync("Assets/Res/Streaming/Prefabs/UI/MainWin.prefab");
            obj.transform.SetParent(GameObject.Find("Canvas").transform);
            obj.transform.localPosition = ViewModel.Position;
            obj.transform.localScale = Vector3.one;

            await Task.CompletedTask;
        }
    }
}